<?php
//企业名片
if(!defined('IN_T')){
	die('hacking attempt');
}

$ajax = intval($_REQUEST['ajax']);
	
$page = intval($_REQUEST['page']);
$page = $page<1? 1: $page;
$size = 20;

$type = intval($_REQUEST['t']);

//刷新页
if(!$ajax){
	$tp->assign("type",$type);
	$tp->assign('types',$Db->query('SELECT name,id FROM '.$Base->table('company_type')));   //查询所有组别
	$tp->assign('is_mobile',Common::is_mobile_visit()?1:0);
}
//ajax
else{
	$res = listMembers($type,$page,$size);
	echo $Json->encode($res);
	exit;
}

function listMembers($type,$page,$size){
	$sql = "select c_id,name,avatar,lowest,is_book from ".$GLOBALS['Base']->table('company_profile')." where 1 ";
	if($type>0){
		$sql .= "and type=$type";
	}
	
	$res['count'] = count($GLOBALS['Db']->query($sql));

	$sql .= ' LIMIT '.($page-1)*$size.','.$size;
	$res = $GLOBALS['Db']->query($sql);

	$res['res'] = $res;
	return $res;
}
?>